package com.itshare.video.common.config;

import com.itshare.video.common.config.resolver.*;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lyr
 * @create 2020/10/24 14:22
 */
@Configuration
public class WebResolverConf implements WebMvcConfigurer {

    @Resource
    private AttrResolver attrResolver;
    @Resource
    private FormDataResolver formDataResolver;
    @Resource
    private PageAndSizeResolver pageAndSizeResolver;

    @Resource
    private JsonBodyResolver jsonBodyResolver;

    @Resource
    private WebDataResolver webDataResolver;

    /**
     * Add resolvers to support custom controller method argument types.
     * <p>This does not override the built-in support for resolving handler
     * method arguments. To customize the built-in support for argument
     * resolution, configure {@link RequestMappingHandlerAdapter} directly.
     *
     * @param resolvers initially an empty list
     */
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {

        resolvers.add(attrResolver);
        resolvers.add(pageAndSizeResolver);
        resolvers.add(formDataResolver);
        resolvers.add(jsonBodyResolver);
        resolvers.add(webDataResolver);

    }
}
